/*
 * @Author: dawei 664690250@qq.com
 * @Date: 2023-04-11 10:30:01
 * @LastEditors: dawei 664690250@qq.com
 * @LastEditTime: 2023-05-05 08:56:55
 * @FilePath: /personal_h5/src/api/auth.js
 * @Description: 请填写文件描述
 * 大佬别走，带带弟弟
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import Cookies from "js-cookie";

const TokenKey = "X-Access-Token";
// const userIdKey = 'userId'

export function getToken() {
  const urlSearchParams = new URLSearchParams(location.search.slice(1));
  const urlToken = urlSearchParams.get("token");
  return urlToken || Cookies.get(TokenKey);
}

export function setToken(token) {
  return Cookies.set(TokenKey, token, { expires: 7 });
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

// export function getUserId() {
//   return Cookies.get(userIdKey)
// }

// export function setUserId(token) {
//   return Cookies.set(userIdKey, token, { expires: 7 })
// }

// export function removeUserId() {
//   return Cookies.remove(userIdKey)
// }
